// MainDlg.h : interface of the CMainDlg class
//
/////////////////////////////////////////////////////////////////////////////
#pragma once
#include "bkwinres.h"
#include "Knowledge\KnowledgeUiHandler.h"
#include "PasswordMgr\PasswordMgrUiHandler.h"
#include "ToolBox\ToolBoxUiHandler.h"
#include "Controls\trayiconimpl.h"
#include "ToolBox\ToolBoxSingleDlg.h"
#include "ToolBox\ToolBoxFloatDlg.h"
//#include <PluginManager/Ix_PluginLoader.h>
#include "Controls\ListCtrl.h"
#include "Http\Request.h"

class Cx_PluginInform;
class CPluginManager;

class CMainDlg 
	: public CBkDialogImpl<CMainDlg>
	, public CWHRoundRectFrameHelper<CMainDlg>
	, public CTrayIconImpl<CMainDlg>
	, public CReqCallback
{
public:
	 DECLARE_WND_CLASS_EX(PKMP_DDE_WND_CLASS, CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, COLOR_WINDOW)
	CMainDlg();
	~CMainDlg();
	void OnBkBtnMax();
    void OnBkBtnMin();
	//void OnBkLblTitleSetting();
    //void OnBkBtnSet();
	void OnBkBtnClose();
	void EndDialog(UINT uRetCode);
	void OnSetting();
	void OnSysSetting();
	CImageList GetilIcons()
	{
		return m_ilIcons;
	}
	void SetStatusPanel1(const CString strMsg);
	void SetStatusPanel2(const CString strMsg);
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	void AddPluginInformToListCtrl(CListCtrl& listCtrl);

	void OnDictImport(int nClass);
	void OnArtImport(int nClass);
	void AddArtFromUrl(CString strTitle,CString strUrl);
	void RefreshTB()
	{
		m_TBDlg.RefreshList();
	}
	std::vector<Cx_PluginInform>	m_Pluginforms;
	CPluginManager*					m_Pluginloader;
protected:
	CToolBoxSingleDlg m_TBDlg;
	CToolBoxFloatDlg  m_FTBDlg;
	
protected:
	CKnowledgeUiHandler*			m_KnowleHandler;
	CPasswordMgrUiHandler*			m_PswMgrHandler;
	CToolBoxUiHandler*				m_ToolBoxHandler;
	CImageList						m_ilIcons;
	//int								m_nFirstShow;
	CString							m_strTitle;
	BOOL OnInitDialog(CWindow /*wndFocus*/, LPARAM /*lInitParam*/);
	void OnSysCommand(UINT nID, CPoint point);
	LRESULT OnAppExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnShowHome(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnShowPassword(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnOpenToolBox(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnHideToolBox(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnOpenFloatWin(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnSetting(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnPluginManager(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);

	LRESULT OnSettingChanged(UINT uMsg, WPARAM wParam, LPARAM lParam);
	void SetAutorunTray(BOOL bOn);
	void OpenDefaultPage();
	void RestoreMainWindow();
	static int AddCategory(int nClass,LPWSTR lpCate);
	static int AddArticle(int nClass,LPWSTR lpTitle,LPWSTR lpContent,LPWSTR lpType);
	
	void OnShowWindow(BOOL bShow, UINT nStatus);
	void OnActivate(UINT nState, BOOL bMinimized, CWindow wndOther);
	BOOL OnCopyData(CWindow wnd, PCOPYDATASTRUCT pCopyDataStruct);
	int SetRegInform();
	virtual void OnRequestComplete(HTTP_RESULTCODE eHttpRetCode,const char* pReqUrl, CReqParam oParam, const char*pData,int nLen);
public:

	BK_NOTIFY_MAP(IDC_RICHVIEW_WIN)
		BK_NOTIFY_ID_COMMAND(IDC_BTN_SYS_CLOSE, OnBkBtnClose)
        BK_NOTIFY_ID_COMMAND(IDC_BTN_SYS_MAX,   OnBkBtnMax)
        BK_NOTIFY_ID_COMMAND(IDC_BTN_SYS_MIN,   OnBkBtnMin)
		BK_NOTIFY_ID_COMMAND(IDC_MAIN_SETTING,   OnSetting)
		BK_NOTIFY_ID_COMMAND(IDC_BTN_SYS_SET,   OnSysSetting)
		
	BK_NOTIFY_MAP_END()
	BEGIN_MSG_MAP_EX_DECLARE(CMainDlg)


};
